/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package negocio;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Jorge
 */
@Entity
@Table(name = "componentes_formula", catalog = "mydb2", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ComponentesFormula.findAll", query = "SELECT c FROM ComponentesFormula c"),
    @NamedQuery(name = "ComponentesFormula.findByIdcomponentesFormula", query = "SELECT c FROM ComponentesFormula c WHERE c.idcomponentesFormula = :idcomponentesFormula"),
    @NamedQuery(name = "ComponentesFormula.findByDescripcion", query = "SELECT c FROM ComponentesFormula c WHERE c.descripcion = :descripcion"),
    @NamedQuery(name = "ComponentesFormula.findByUnidad", query = "SELECT c FROM ComponentesFormula c WHERE c.unidad = :unidad")})
public class ComponentesFormula implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "idcomponentes_formula", nullable = false)
    private Integer idcomponentesFormula;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 500)
    @Column(nullable = false, length = 500)
    private String descripcion;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(nullable = false, length = 100)
    private String unidad;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idcomponentesFormula")
    private List<DetalleValor> detalleValorList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idcomponentesFormula1")
    private List<Formula> formulaList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idcomponentesFormula2")
    private List<Formula> formulaList1;

    public ComponentesFormula() {
    }

    public ComponentesFormula(Integer idcomponentesFormula) {
        this.idcomponentesFormula = idcomponentesFormula;
    }

    public ComponentesFormula(Integer idcomponentesFormula, String descripcion, String unidad) {
        this.idcomponentesFormula = idcomponentesFormula;
        this.descripcion = descripcion;
        this.unidad = unidad;
    }

    public Integer getIdcomponentesFormula() {
        return idcomponentesFormula;
    }

    public void setIdcomponentesFormula(Integer idcomponentesFormula) {
        this.idcomponentesFormula = idcomponentesFormula;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public String getUnidad() {
        return unidad;
    }

    public void setUnidad(String unidad) {
        this.unidad = unidad;
    }

    @XmlTransient
    public List<DetalleValor> getDetalleValorList() {
        return detalleValorList;
    }

    public void setDetalleValorList(List<DetalleValor> detalleValorList) {
        this.detalleValorList = detalleValorList;
    }

    @XmlTransient
    public List<Formula> getFormulaList() {
        return formulaList;
    }

    public void setFormulaList(List<Formula> formulaList) {
        this.formulaList = formulaList;
    }

    @XmlTransient
    public List<Formula> getFormulaList1() {
        return formulaList1;
    }

    public void setFormulaList1(List<Formula> formulaList1) {
        this.formulaList1 = formulaList1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idcomponentesFormula != null ? idcomponentesFormula.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ComponentesFormula)) {
            return false;
        }
        ComponentesFormula other = (ComponentesFormula) object;
        if ((this.idcomponentesFormula == null && other.idcomponentesFormula != null) || (this.idcomponentesFormula != null && !this.idcomponentesFormula.equals(other.idcomponentesFormula))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "negocio.ComponentesFormula[ idcomponentesFormula=" + idcomponentesFormula + " ]";
    }
    
}
